package com.moefor.clover.model;

import java.util.Date;
import java.util.Set;

import javax.persistence.*;

import com.moefor.clover.model.element.Picture;
@Entity
public class User extends BaseEntity{
	@Column(unique = true, nullable = false)
	private String username;
	
	public Picture getAvator() {
		return avator;
	}

	public void setAvator(Picture avator) {
		this.avator = avator;
	}

	public Set<Comment> getReplyItems() {
		return replyItems;
	}

	public void setReplyItems(Set<Comment> replyItems) {
		this.replyItems = replyItems;
	}

	@Column(unique = true, length = 32)
	private String password;
	
	@Column
	private String email;
	
	@Column
	private Picture avator;
	
	@Column(length = 16)
	private String tel;
	
	@Column(name = "last_login_time")
	private Date lastLoginTime;
	
	@Column(name = "last_login_ip", length = 39)
	private String lastLoginIp;
	
	@OneToMany(mappedBy = "owner", fetch = FetchType.LAZY, cascade = {CascadeType.ALL})
	private Set<Goods> goodsItems;
	
	@OneToMany(mappedBy = "author", fetch = FetchType.LAZY, cascade = {CascadeType.ALL})
	private Set<Comment> commentItems;
	
	@OneToMany(mappedBy = "reply", fetch = FetchType.LAZY, cascade = {CascadeType.ALL})
	private Set<Comment> replyItems;
	
	@OneToMany(mappedBy = "customer", fetch = FetchType.LAZY, cascade = {CascadeType.ALL})
	private Set<Order> orderItems;
	
	@OneToMany(mappedBy = "receiver", fetch = FetchType.LAZY, cascade = {CascadeType.ALL})
	private Set<Message> receivedMessageItems;
	
	@OneToMany(mappedBy = "sender", fetch = FetchType.LAZY, cascade = {CascadeType.ALL})
	private Set<Message> sendMessageItems;

	public Set<Message> getReceivedMessageItems() {
		return receivedMessageItems;
	}

	public void setReceivedMessageItems(Set<Message> receivedMessageItems) {
		this.receivedMessageItems = receivedMessageItems;
	}

	public Set<Message> getSendMessageItems() {
		return sendMessageItems;
	}

	public void setSendMessageItems(Set<Message> sendMessageItems) {
		this.sendMessageItems = sendMessageItems;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getTel() {
		return tel;
	}

	public void setTel(String tel) {
		this.tel = tel;
	}

	public Date getLastLoginTime() {
		return lastLoginTime;
	}

	public void setLastLoginTime(Date lastLoginTime) {
		this.lastLoginTime = lastLoginTime;
	}

	public String getLastLoginIp() {
		return lastLoginIp;
	}

	public void setLastLoginIp(String lastLoginIp) {
		this.lastLoginIp = lastLoginIp;
	}

	public Set<Goods> getGoodsItems() {
		return goodsItems;
	}

	public void setGoodsItems(Set<Goods> goodsItems) {
		this.goodsItems = goodsItems;
	}

	public Set<Comment> getCommentItems() {
		return commentItems;
	}

	public void setCommentItems(Set<Comment> commentItems) {
		this.commentItems = commentItems;
	}

	public Set<Order> getOrderItems() {
		return orderItems;
	}

	public void setOrderItems(Set<Order> orderItems) {
		this.orderItems = orderItems;
	} 
	
}
